package com.csi.service.impl;

import com.csi.domain.Hotel;
import com.csi.domain.TravelAttraction;
import com.csi.domain.TravelPackage;
import com.csi.domain.Trip;
import com.csi.mapper.TravelMapper;
import com.csi.service.TravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class TravelServiceImpl implements TravelService {

    @Autowired
    private TravelMapper travelMapper;

    /**
     * 查询不同类型的旅游套餐
     * @return
     */
    @Override
    public Map<String, List<Map<String,Object>>> findByType() {
        List<String> types = travelMapper.findType();
        Map<String, List<Map<String,Object>>> map = new HashMap<>();
        for (String type : types) {
            List<Map<String,Object>> list = travelMapper.findByType(type);
            map.put(type, list);
        }
        return map;
    }

    /**
     * 查询旅游套餐详情
     * @param id
     * @return
     */
    @Override
    public TravelPackage packageInfo(Long id) {
        return travelMapper.packageInfo(id);
    }

    @Override
    public Trip trip(Long id) {
        return travelMapper.trip(id);
    }

    @Override
    public List<Map<String, Object>> findAll() {
        return travelMapper.findAll();
    }

    @Override
    public String findName(long travelId) {
        return travelMapper.findName(travelId);
    }

    @Override
    public List<TravelPackage> findPackage(long travelId) {
        return travelMapper.findPackage(travelId);
    }

    @Override
    public Hotel travelHotel(Long id) {
        return travelMapper.travelHotel(id);
    }

    @Override
    public List<TravelAttraction> travelAttraction(Long id) {
        return travelMapper.travelAttraction(id);
    }
}
